package service.impl;



import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import common.dao.BookReviewMapper;
import common.pojo.BookReview;
import common.utils.Constants;

@Service
public class BookReviewServiceImpl {


	@Autowired
    private BookReviewMapper mapper;

	public int queryByCount(BookReview bookReview) {
		// TODO Auto-generated method stub
		return mapper.queryByCount(bookReview);
	}

	public List<BookReview> find(int start, Integer limit) {
		return mapper.queryListByWhere(" br join member m on br.member_id=m.id  where br.deleted="
				+ Constants.NOT_DELETED + " order by br.create_time desc limit "
				+ start + "," + limit);
	}

	public void delete(String ids, String adminName) {
		String[] id = StringUtils.split(ids, ",");
		BookReview br = new BookReview();
		for (int i = 0; i < id.length; i++) {
			if (StringUtils.isNotBlank(id[i])) {
				br.setDeleted(Constants.DELETED);
				br.setUpdateName(adminName);
				br.setUpdateTime(new Date());
				br.setId(Integer.valueOf(id[i]));
				mapper.updateBySelective(br);
			}
		}
	}

}
